package ObjectAndObjects;

import java.util.Objects;

public class Test2 {
    public static void main(String[] args) {

        Student s1=new Student("lala",23);
        Student s2=new Student("lala",23);

        //如果没重写方法比的是地址值，重写就比较属性值
        boolean res=s1.equals(s2);
        System.out.println(res);//true

        System.out.println("-----------------------------");

        Student s3=null;
        boolean res1= Objects.equals(s3,s1);
        System.out.println(res1);//false
        //方法底层会先判断s3是否为空，如果为null直接返回false

        System.out.println("-----------------------------");

        Student s4=new Student();
        Student s5=null;
        //判断是否为空
        System.out.println(Objects.isNull(s4));//false
        System.out.println(Objects.isNull(s5));//true
        //判断是否不为空
        System.out.println(Objects.nonNull(s4));//true
        System.out.println(Objects.nonNull(s5));//false
    }
}
